var app, ns;
app = new Vue({
    el: '#app',
    data: {
    },
    methods: {
        open_home_index: function () {
            console.log(123)
            var delay = 0;
            if (api.systemType != 'ios') {
                delay = 100;
            }
            api.openFrame({
                name: 'main_home_index',
                url: 'home_index.html',
                delay: delay,
                slidBackEnabled: false,
                vScrollBarEnabled: false,
                rect: {
                    x: 0,
                    y: 0,
                    w: 'auto',
                    h: 'auto'
                }
            });
        },
        btnOk: function () {
            var that = this;
            api.setPrefs({
                key: 'agreementDone',
                value: '1'
            });
            that.open_home_index();
        },
        btnNo: function () {
            var that = this;
            api.closeWidget({
                silent: true
            });
        },
        openAll: function (type) {
            api.openFrame({
                name: 'dl_register_agree_frm',
                url: 'html/dl_register_agree_frm.html',
                rect: {
                    x: 0,
                    y: 0,
                    w: api.winWidth,
                    h: api.winHeight
                },
                pageParam: {
                    Type: type,
                    answer: 1
                },
                //bgColor: 'rgba(0,0,0,0.6)',
                bounces: false
            });
        },
    }
});
apiready = function () {
    api.parseTapmode();
    ns = window.Foresight.Util;
    var last_out_time;
    api.addEventListener({
        name: 'do_agree'
    }, function (ret, err) {
        app.btnOk();
    });
    api.addEventListener({
        name: 'keyback'
    }, function (ret, err) {
        if (last_out_time && last_out_time.valueOf() >= (new Date().valueOf() - 1000)) {
            api.closeWidget({
                silent: true
            });
            return;
        }
        last_out_time = new Date();
        api.toast({
            msg: '再按一次退出程序',
            duration: 1000
        });
    });
    api.removeLaunchView({
        animation: {
            type: 'fade',
            duration: 500
        }
    });
    
};
